package com.ruoyi.system.enums;

import lombok.Getter;
import java.util.ArrayList;
import java.util.List;

/**
 * 空间类型枚举类
 */
@Getter
public enum SpaceTypeEnum {
    LIVING_ROOM("客厅", "LIVING_ROOM"),
    BEDROOM("卧室", "BEDROOM"),
    DINING_ROOM("餐厅", "DINING_ROOM"),
    TOILET("卫生间", "TOILET"),
    KITCHEN("厨房", "KITCHEN"),
    STUDY_ROOM("书房", "STUDY_ROOM"),
    BALCONY("阳台", "BALCONY"),
    ATTIC("阁楼", "ATTIC"),
    OTHER("其他", "OTHER");

    private final String label;
    private final String value;

    SpaceTypeEnum(String label, String value) {
        this.label = label;
        this.value = value;
    }

    /**
     * 根据值获取枚举
     */
    public static SpaceTypeEnum getByValue(String value) {
        for (SpaceTypeEnum type : values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        return null;
    }
    /**
     * 根据label匹配枚举
     */
    public static SpaceTypeEnum getByLabel(String value) {
        for (SpaceTypeEnum type : values()) {
            if (value.contains(type.label) || type.label.contains(value)) {
                return type;
            }
        }
        return null;
    }

    /**
     * 获取所有空间类型列表
     */
    public static List<TypeVO> getAllTypes() {
        List<TypeVO> list = new ArrayList<>();
        for (SpaceTypeEnum type : values()) {
            list.add(new TypeVO(type.value, type.label));
        }
        return list;
    }

    /**
     * 空间类型VO类
     */
    public static class TypeVO {
        private String value;
        private String label;

        public TypeVO(String value, String label) {
            this.value = value;
            this.label = label;
        }

        // getter and setter
        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getLabel() {
            return label;
        }

        public void setLabel(String label) {
            this.label = label;
        }
    }
}
